

public class Tower extends Structure{
	
	static int towerID =1;
	Tower(int _x, int _y){
		super(_x,_y);
		type = TOWER;
		label = 'T';
		ID = towerID++;
		map.visible(_x, _y, range[TOWER]);
		map.setLabel(_x, _y, label);
	}


	int endTick() {
		int needed=0, total = metalRT + energyRT + nutrientRT;
		
		if(!damage(damage)){
			die();
			return -1;
		}
		damage = 0;

		
		if(metal - metalRT >= 0)
			metal -= metalRT;
		else{
			needed += metalRT - metal;
			metal = 0;
		}
		
		if(energy - energyRT >= 0)
			energy -= energyRT;
		else{
			needed += energyRT - energy;
			energy = 0;
		}
		
		if(nutrient - nutrientRT >= 0)
			nutrient -= nutrientRT;
		else{
			needed += nutrientRT - nutrient;
			nutrient = 0;
		}

		if(needed > 0)
			if(damage((float)(needed)/total/2))
				return 0;
			else{
				die();
				return -1;
			}
		return 1;
	}

	

	void heal(int x) {damage -= x;}

	public void addCommand(int[] command) {commandQueue.put(command);}


	public void delCommands() {
		// TODO delete commands from queue
	}


	public boolean die() {
		map.invisible(x,y,range[TOWER]);
		return super.die();
	}

	
	public int getStatus() {
		// TODO return status array
		return 0;
	}


	public String[] gettxtCommands() {
		// TODO Auto-generated method stub
		return null;
	}


	public String[] gettxtStatus() {
		// TODO list text commands
		return null;
	}


	public void powerDown() {
		
		
	}

	@Override
	public void powerUp() {
		// TODO Auto-generated method stub	
	}
}
